package kg.aibek.helper;

import java.util.ArrayList;
import java.util.List;

public class Sequence {
	private int length;
	private List<Integer> seq;
	private int sec;

	public Sequence(int length) {
		this.length = length;
		seq = new ArrayList<Integer>(length);
		sec = 0;
	}

	public boolean addNumber(int number) {
		if (seq.size() < length) {
			seq.add(number);
			return true;
		} else {
			if (sec == length) {
				sec = 0;
			}
			return seq.get(sec++) == number;
		}
	}

	public List<Integer> getSeq() {
		return seq;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		for (Integer i : seq) {
			sb.append(i + " ");
		}
		return sb.toString();
	}
}
